/*
* This software is licensed under the GNU General Public License, version 2
* You may copy, distribute and modify the software as long as you track changes/dates of in source files and keep all modifications under GPL. You can distribute your application using a GPL library commercially, but you must also provide the source code.

* DNNspot Software (http://www.dnnspot.com)
* Copyright (C) 2013 Atriage Software LLC
* Authors: Kevin Southworth, Matthew Hall, Ryan Doom

* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

* Full license viewable here: http://www.gnu.org/licenses/gpl-2.0.txt
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security.Membership;
using DotNetNuke.Entities.Users;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Security;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Entities.Tabs;
using System.Collections;

namespace DNNspot.Sitemap
{
    public partial class Default : ModuleBase
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            _ShowHiddenMenuItems = Convert.ToBoolean(Settings["IncludeHidden"]);
            _ShowViewEditPermissions = Convert.ToBoolean(Settings["ShowViewEditPermissions"]);
            _SitemapLevel = !String.IsNullOrEmpty(Convert.ToString(Settings["_SitemapLevel"])) ? Convert.ToInt32(Settings["_SitemapLevel"]) : 0;
            _SitemapStart = !String.IsNullOrEmpty(Convert.ToString(Settings["SitemapStart"])) ? Convert.ToInt32(Settings["SitemapStart"]) : -1;
            _PortalId = !String.IsNullOrEmpty(Convert.ToString(Settings["PortalToUse"])) ? Convert.ToInt32(Convert.ToString(Settings["PortalToUse"])) : PortalId;
            _PortalAlias = !String.IsNullOrEmpty(Convert.ToString(Settings["PortalAliasToUse"])) ? Convert.ToString(Settings["PortalAliasToUse"]) : String.Empty;

            if (_SitemapStart == 0)
                _SitemapStart = -1;

            try
            {
                string tabidexclude = Convert.ToString(Settings["TabIdExclude"]);
                _ExcludedTabs = tabidexclude.Split(',');
            }
            catch (Exception ex)
            {
                

            }
            sitemapOutput.Text = GenerateSitemap(PortalSettings.ActiveTab);
            //DumpRawData();
        }
    }
}